// index.ts
// 获取应用实例
const app = getApp<IAppOption>();
import router from "../../vendor/router";
import http from "../../vendor/http";
import { behavior } from "../../models/behavior";
Page({
  behaviors: [behavior],
  data: {},
  onLoad() {
    // this.testFuncs();
    // this.testRouter();
    // this.testProcess()
  },
  testProcess() {
    this.test_req_2();
    this.test_req_1();
    this.test_req_3();
    this.test_login();
  },
  test_login() {
    wx.login({
      success(res) {
        http.fetchPost("/activityPlatform/wxMember/miniLogin", {
          code: res.code,
          is_login: 1,
        }).then((res:any)=>{
          app.globalData.accessToken  = res.token
          app.globalData.refreshAfter  = 1674982945  // test 
        });
      },
    });
  },
  test_req_1() {
    http
      .fetchPost("/activityPlatform/wxSetting/getSetting", {
        page_router: "index",
      })
      .then((res) => {
        console.log("req_1:", res);
      });
  },
  test_req_2() {
    http
      .fetchPost("/activityPlatform/wxAdv/getAdvsByIds", { adv_ids: "4" })
      .then((res) => {
        console.log("req_2:", res);
      });
  },
  test_req_3() {
    http
      .fetchPost("/activityPlatform/wxCommunity/circlesAndActivities", {
        page: 1,
        size: 10,
      })
      .then((res) => {
        console.log("req_3:", res);
      });
  },
  testRouter() {
    router.push({
      name: "test",
    });
  },
  testFuncs() {
    http.fetchGet("", { a: 1, b: 2 });
    http.fetchGet("", { a: 1 });
  },
});
